﻿using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Effects;

namespace ServiceApp
{
    public class GlassBorder : Border
    {
        private readonly Border _contentHost;

        public GlassBorder()
        {
            // 基础设置
            CornerRadius = new CornerRadius(10);
            BorderBrush = Brushes.Black;
            BorderThickness = new Thickness(2);

            // 创建内容宿主（不会添加到视觉树）
            _contentHost = new Border
            {
                Background = Brushes.White,
                CornerRadius = new CornerRadius(10),
                Child = new TextBlock
                {
                    Text = "这里是内容",
                    Margin = new Thickness(20)
                }
            };

            // 设置视觉画刷
            Background = new VisualBrush(_contentHost)
            {
                Stretch = Stretch.None,
                AlignmentX = AlignmentX.Left,
                AlignmentY = AlignmentY.Top,
                RelativeTransform = new TranslateTransform { X = -10, Y = -10 }
            };

            // 添加模糊效果
            Effect = new BlurEffect { Radius = 8 };
        }

        // 内容属性
        public object GlassContent
        {
            get => _contentHost.Child;
            set => _contentHost.Child = value as UIElement;
        }
    }
}